import 'package:flutter/material.dart';

class BottomBarProvider with ChangeNotifier {
  int curPage = 0;
  PageController controller = PageController();
  IconData homeIcon = const IconData(0xe611, fontFamily: 'MyIcons');
  IconData liveIcon = const IconData(0xe61c, fontFamily: 'MyIcons');
  IconData mineIcon = const IconData(0xe502, fontFamily: 'MyIcons');

  Color colorActive = Colors.red;
  Color colorDefault = Colors.black45;
  Color home = Colors.black45;
  Color live = Colors.black45;
  Color mine = Colors.black45;

  BottomBarProvider();

  void goToPage(int curPage) {
    if (this.curPage == curPage) {
      return;
    }
    controller.jumpToPage(curPage);
    this.curPage = curPage;

    homeIcon = const IconData(0xe607, fontFamily: 'MyIcons');
    liveIcon = const IconData(0xe61c, fontFamily: 'MyIcons');
    mineIcon = const IconData(0xe502, fontFamily: 'MyIcons');
    if (curPage == 0) {
      home = colorActive;
      homeIcon = const IconData(0xe611, fontFamily: 'MyIcons');
    } else if (curPage == 1) {
      live = colorActive;
      liveIcon = const IconData(0xe624, fontFamily: 'MyIcons');
    } else if (curPage == 2) {
      mine = colorActive;
      mineIcon = const IconData(0xe774, fontFamily: 'MyIcons');
    }

    notifyListeners();
  }
}
